// app.js
App({
    onLaunch() {
        this.getLogUser();
    },
    getLogUser(cb) {
    
        var sto_userinfo = wx.getStorageSync('sto_userinfo');
       
        if (sto_userinfo.length > 10) {
          typeof cb == "function" && cb(sto_userinfo);
        } else {
          console.log('4243')
          // 登录
          wx.login({
            success(res) {
              if (res.code) {
                wx.request({
                  url: 'https://mnp.zhusiot.com/Mini/BalCard.ashx?action=1',
                  dataType: "json",
                  data: {
                    jsCode: res.code
                  },
                  header: {
                    'content-type': 'application/json' // 默认值
                  },
                  success(resp) {
                    var respd = resp.data;
                    if (respd.getNum == 0) {
                      wx.setStorageSync('sto_userinfo', respd.getMsg);
                      typeof cb == "function" && cb(respd.getMsg);
                    }
                  }
                });
              }else{
                console.log(res)
              }
            },
            fail(res){
              console.log(res)
            }
          });
        }
    },
 
   globalData: {
        apiUrl: "https://mnp.zhusiot.com/",
        apiUrlNew:"https://h501.zhusiot.com/",
         
    }
})
